package com.egao.go.service.impl;

import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
//import com.egao.go.mapper.DutchUserMapper;
import com.egao.go.entity.DutchUser;
import com.egao.go.service.DutchUserService;
import org.springframework.stereotype.Service;
import com.egao.go.biz.DutchUserBiz;
import net.sf.json.JSONObject;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
//import javax.transaction.Transactional;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 报名人服务实现类
 * @author : Doman
 * @date : 2020-09-20 17:25:43
 * @version ：1.0
 */
@Service
public class DutchUserServiceImpl /*extends ServiceImpl<DutchUserMapper, DutchUser> */implements DutchUserService {

	@Autowired
	private DutchUserBiz dutchUserBiz;

    /**
    @Override
    public PageResult<DutchUser> listPage(PageParam<DutchUser> page) {
        List<DutchUser> records = baseMapper.listPage(page);
        return new PageResult<>(records, page.getTotal());
    }

    @Override
    public List<DutchUser> listAll(Map<String, Object> page) {
        return baseMapper.listAll(page);
    } */

    @Override
    public JsonResult list(PageResult2<T> page, DutchUser dutchUser, User loginUser)  throws Exception{
        return dutchUserBiz.list(page,dutchUser,loginUser);
    }

    @Override
    public JsonResult list(DutchUser dutchUser, User loginUser) {
        return JsonResult.ok().setData(dutchUserBiz.list(dutchUser,loginUser));
    }

    @Override
    public JsonResult getById(DutchUser dutchUser) {
        return JsonResult.ok().setData(dutchUserBiz.getById(dutchUser));
    }

    @Transactional
    @Override
    public JsonResult save(DutchUser dutchUser, User loginUser) {
        int id = dutchUserBiz.save(dutchUser, loginUser);
        return JsonResult.ok("添加成功").put("id", id);
    }

    @Transactional
    @Override
    public JsonResult update(DutchUser dutchUser, User loginUser) {
        if (dutchUserBiz.update(dutchUser, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Transactional
    @Override
    public JsonResult remove(DutchUser dutchUser, User loginUser) {
        if (dutchUserBiz.remove(dutchUser, loginUser)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }

}
